//*****************************************************************************
// JFab (http://code.google.com/p/jfab)
// Copyright (c) 2011-2012 JFab.org
// Admin jfab@jeffreythompson.net
//
// See the file "LICENSE.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//*****************************************************************************

package org.jfab.swingui.decorator;

import org.apache.commons.lang3.Validate;
import org.jfab.core.factory.ModelFactory;
import org.jfab.swingui.IconManager;

/**
 * Provides base functionality for a decorator.
 * 
 * @param <T> Component type.
 */
public abstract class AbstractDecorator<T> implements Decorator<T>
{
    /** Decorator factory. */
    private static final DecoratorFactory DECORATOR_FACTORY = new DecoratorFactory();

    /** Model factory. */
    private static final ModelFactory MODEL_FACTORY = new ModelFactory();

    /**
     * @return the decoratorFactory
     */
    protected static DecoratorFactory getDecoratorFactory()
    {
        return DECORATOR_FACTORY;
    }

    /**
     * @return the ModelFactory
     */
    protected static ModelFactory getModelFactory()
    {
        return MODEL_FACTORY;
    }

    /** Component. */
    private final T _component;

    /** Icon manager. */
    private final IconManager _iconManager;

    /** Parent. */
    private final Decorator<?> _parent;

    /**
     * Construct this object with the given parameters.
     * 
     * @param component Component. (required)
     * @param parent Parent.
     * @param iconManager Icon manager. (required)
     */
    public AbstractDecorator(final T component, final Decorator<?> parent,
            final IconManager iconManager)
    {
        Validate.notNull(component, "component is null");
        Validate.notNull(iconManager, "iconManager is null");

        _component = component;
        _parent = parent;
        _iconManager = iconManager;
    }

    @Override
    public T getComponent()
    {
        return _component;
    }

    /**
     * @return the parent
     */
    @Override
    public Decorator<?> getParent()
    {
        return _parent;
    }

    /**
     * @return the iconManager
     */
    protected IconManager getIconManager()
    {
        return _iconManager;
    }
}
